<template>
  <div class="sjht-card" :class="{ 'sjht-card-border': border }" @click.stop="onClick">
    <div v-if="isTitle" class="sjht-card-header" :class="{ 'van-hairline--bottom': titleBorder }">
      <div class="sjht-card-title">
        <slot name="title">{{ title }}</slot>
      </div>
      <div v-if="$slots.extra" class="sjht-card-extra">
        <slot name="extra"></slot>
      </div>
    </div>
    <div class="sjht-card-content">
      <slot></slot>
    </div>
    <slot name="footer"></slot>
  </div>
</template>
<script>
export default {
  name: 'SjhtCard',
  props: {
    //标题
    title: {
      type: String,
      default: null
    },
    //是否显示边框
    border: {
      type: Boolean,
      default: false
    },
    //标题是否显示低边框
    titleBorder: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    isTitle: function () {
      return this.$slots.title || Boolean(this.title)
    }
  },
  methods: {
    onClick() {
      this.$emit('click')
    }
  }
}
</script>
<style lang="less">
.sjht-card {
  position: relative;
  background-color: #fff;
  box-shadow: 0px 6px 15px 0px rgba(3, 121, 234, 0.1);
  border-radius: 10px;
  &-border {
    box-shadow: 0px 6px 15px 0px rgba(153, 153, 153, 0.2);
    border: 1px solid rgba(204, 204, 204, 0.2);
  }
  &-header {
    color: #333;
    font-size: 14px;
    margin: 0 16px;
    // min-height: 50px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }
  &-title {
    display: inline-block;
    flex: 1;
    padding: 10px 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  &-extra {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
  }
  &-content {
    padding: 0 16px;
  }
}
</style>
